unit Ocorrencia;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, UFomCadastro, Mask, DBCtrls, DB, ExtCtrls, DBClient, Provider,
  DBTables, Menus, StdCtrls, ComCtrls, Buttons, Grids, DBGrids, ToolEdit,
  RXDBCtrl;

type
  TFOcorrencia = class(TFormCadastro)
    Label1: TLabel;
    Label2: TLabel;
    edPedNF: TEdit;
    edPedItem: TEdit;
    DBRadioGroup1: TDBRadioGroup;
    cdsCadastroITENS_PED_PEDIDO: TIntegerField;
    cdsCadastroITENS_PED_PRODUTO: TIntegerField;
    cdsCadastroITENS_PED_QUANTIDADE: TFloatField;
    cdsCadastroITENS_PED_QUANTIDADEATEN: TFloatField;
    cdsCadastroITENS_PED_VALOR: TFloatField;
    cdsCadastroITENS_PED_SITUACAO: TIntegerField;
    cdsCadastroITENS_PED_VALOR_TOTAL: TFloatField;
    cdsCadastroITENS_PED_LOCAL: TIntegerField;
    cdsCadastroITENS_PED_OUTROS_VALORES: TFloatField;
    cdsCadastroITENS_PED_PERC_IPI: TFloatField;
    cdsCadastroITENS_PED_VALOR_IPI: TFloatField;
    cdsCadastroITENS_PED_NF: TStringField;
    cdsCadastroUSUARIO_CADASTRO: TStringField;
    cdsCadastroUSUARIO_AUTERACAO: TStringField;
    cdsCadastroUSUARIO_EXCLUSAO: TStringField;
    cdsCadastroDATA_CADASTRO: TDateTimeField;
    cdsCadastroDATA_EXCLUSAO: TDateTimeField;
    cdsCadastroDATA_AUTERACAO: TDateTimeField;
    cdsCadastroEXCLUIDO: TStringField;
    cdsCadastroITENS_PED_PRODUTO_DESC: TStringField;
    cdsCadastroITENS_PED_DATAATEND: TDateTimeField;
    cdsCadastroITENS_PED_NFATEND: TIntegerField;
    cdsCadastroITENS_PED_IGUALDADE: TStringField;
    cdsCadastroITENS_PED_CONFERENCIA: TStringField;
    cdsCadastroITENS_PED_PENDENCIA: TStringField;
    DBRadioGroup2: TDBRadioGroup;
    DBRadioGroup3: TDBRadioGroup;
    cdsCadastroITENS_PED_OBS1: TStringField;
    cdsCadastroITENS_PED_OBS2: TStringField;
    Label3: TLabel;
    DBEdit1: TDBEdit;
    Label4: TLabel;
    DBEdit2: TDBEdit;
    dbg: TDBGrid;
    Label5: TLabel;
    cdsCadastroITENS_PED_CODIGO: TIntegerField;
    cdsCadastroITENS_PED_DATACONF: TDateTimeField;
    DBDateEdit1: TDBDateEdit;
    procedure edPedNFChange(Sender: TObject);
    procedure edPedItemChange(Sender: TObject);
    procedure BtnIncluirClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormShow(Sender: TObject);
    procedure BtnSalvarClick(Sender: TObject);
  private
    { Private declarations }
    procedure Filtrando;

  public
    { Public declarations }
  end;

var
  FOcorrencia: TFOcorrencia;

implementation

uses RelatorioConferenciaPedidoNF;

{$R *.dfm}

{ TFOcorrencia }

procedure TFOcorrencia.Filtrando;
var
  Filtro : String;
begin

  Filtro := '';

  cdsCadastro.Filtered := False;

  if edPedNF.Text = '' then
    Exit;

  Filtro := Filtro + '(ITENS_PED_PEDIDO = ' + edPedNF.Text + ')';

  if trim(edPedItem.Text) <> '' then
    Filtro := Filtro + 'AND (ITENS_PED_PRODUTO = ' + edPedItem.Text + ')';

  cdsCadastro.Filter   := Filtro;
  cdsCadastro.Filtered := True;

end;

procedure TFOcorrencia.edPedNFChange(Sender: TObject);
begin
  inherited;
  Filtrando;
end;

procedure TFOcorrencia.edPedItemChange(Sender: TObject);
begin
  inherited;

  Filtrando;

end;

procedure TFOcorrencia.BtnIncluirClick(Sender: TObject);
begin
  //inherited;

end;

procedure TFOcorrencia.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  inherited;
  FOcorrencia.release;
  FOcorrencia := Nil;
end;

procedure TFOcorrencia.FormShow(Sender: TObject);
begin
  inherited;
  pcCadastro.ActivePageIndex:=1;
  TsPesquisa.TabVisible := False;
end;

procedure TFOcorrencia.BtnSalvarClick(Sender: TObject);
begin
  inherited;
  cdsCadastro.Refresh;

  if FRelatorioConferenciaPedidoNF <> Nil then
    FRelatorioConferenciaPedidoNF.btnPesquisarClick(Sender);

end;

end.
